﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;

namespace KPIS.GERP.Models.HRM
{
    [Table("hrm_ps_absence_rules")]
    public class RuleAbsence
    {
        [Key, Column("rule_seq"), DataMember, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public int RuleAbsenceId { get; set; }

        [Column("emp_type_seq"), DataMember, ForeignKey("EmpType")]
        public int EmpTypeId { get; set; }

        [Column("absence_type_seq"), DataMember, ForeignKey("AbsenceType")]
        public int AbsenceTypeId { get; set; }

        // ลาล่วงหน้า
        [Column("send_before"), DataMember]
        public int? SendBefore { get; set; }

        // คำนวนวันลา นับรวมวันหยุดหรือไม่
        [Column("include_nwd"), DataMember]
        public bool IncludeNwd { get; set; }

        [Column("quota_day"), DataMember]
        public decimal? DayLimit { get; set; }

        [Column("quota_salary"), DataMember]
        public decimal? DayLimitFullSalary { get; set; }

        [Column("quota_half_salary"), DataMember]
        public decimal? DayLimitHalfSalary { get; set; }

        [Column("quota_count"), DataMember]
        public decimal? TimeLimit { get; set; }

        [Column("quota_day_count"), DataMember]
        public decimal? DayPerTimeLimit { get; set; }
        
        [Column("quota_day_carry_type"), DataMember]
        public DayCarryType DayCarryType { get; set; }

        [Column("quota_day_carry"), DataMember]
        public decimal? DayCarryLimit { get; set; }

        [Column("gender_seq"), DataMember, ForeignKey("Gender")]
        public int? GenderSeq { get; set; }

        [Column("remarks"), DataMember]
        public string Remarks { get; set; }

        [Column("record_status"), DataMember]
        public virtual string RecordStatus { get; set; }

        [Column("created_by"), DataMember]
        public virtual int? CreatedBy { get; set; }

        [Column("created_when"), DataMember]
        public virtual DateTime? CreatedWhen { get; set; }

        [Column("updated_by"), DataMember]
        public virtual int? UpdatedBy { get; set; }

        [Column("updated_when"), DataMember]
        public virtual DateTime? UpdatedWhen { get; set; }
        
        public virtual MasEmployeeType EmpType { get; set; }

        public virtual PsAbsenceType AbsenceType { get; set; }

        public virtual MasGender Gender { get; set; }
    }

    public enum DayCarryType
    {
        NoCarry = 0,
        CarryAll  = 1,
        CarryLimit = 2
    }
}